<?php

class User extends CI_Controller
{

    private static $layout_data = array();
    private static $home_data = array();

    function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        
    }

    /**
     * Login function
     */
    public function login()
    {
        if ($this->input->post('login'))
        {
            $username = $this->input->post('username');
            $password = $this->input->post('password');

            if ($username == 'admin' AND $password == 'onew@y')
            {
                $this->session->set_userdata('is_admin', 1);
            }
            else
            {
                self::$home_data['error'] = 'Sai mật khẩu';
            }
        }

        redirect($_SERVER['HTTP_REFERER']);
    }

    public function logout()
    {
        @$this->session->unset_userdata('is_admin');
        @$this->session->unset_userdata('user_id');
        @$this->session->unset_userdata('username');

        redirect($_SERVER['HTTP_REFERER']);
    }

}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */